```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>线程池配置的艺术与科学</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background-color: #f8fafc;
            color: #1e293b;
            line-height: 1.6;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #d946ef 100%);
        }
        .text-gradient {
            background: linear-gradient(90deg, #6366f1, #d946ef);
            -webkit-background-clip: text;
            background-clip: text;
            color: transparent;
        }
        .card-hover {
            transition: all 0.3s ease;
        }
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
        }
        .highlight-box {
            position: relative;
            padding-left: 1.5rem;
        }
        .highlight-box:before {
            content: "";
            position: absolute;
            left: 0;
            top: 0;
            bottom: 0;
            width: 4px;
            background: linear-gradient(to bottom, #6366f1, #d946ef);
            border-radius: 2px;
        }
        .drop-cap:first-letter {
            float: left;
            font-size: 4.5rem;
            line-height: 0.7;
            margin: 0.15em 0.05em 0 0;
            color: #6366f1;
            font-weight: 700;
        }
    </style>
</head>
<body class="min-h-screen">
    <!-- Hero Section -->
    <section class="hero-gradient text-white">
        <div class="container mx-auto px-6 py-24">
            <div class="max-w-3xl mx-auto text-center">
                <h1 class="text-4xl md:text-6xl font-bold mb-6">线程池配置的<span class="text-yellow-300">艺术</span>与<span class="text-emerald-300">科学</span></h1>
                <p class="text-xl md:text-2xl mb-8 font-light opacity-90">优化系统性能的关键参数选择</p>
                <div class="flex justify-center space-x-4">
                    <a href="#intro" class="px-6 py-3 bg-white text-indigo-600 font-semibold rounded-lg shadow-md hover:bg-gray-100 transition duration-300">
                        <i class="fas fa-book-open mr-2"></i>开始阅读
                    </a>
                    <a href="#visualization" class="px-6 py-3 bg-indigo-900 bg-opacity-50 text-white font-semibold rounded-lg hover:bg-opacity-70 transition duration-300">
                        <i class="fas fa-chart-line mr-2"></i>快速查看
                    </a>
                </div>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <main class="container mx-auto px-6 py-12 max-w-5xl">
        <!-- Intro Section -->
        <section id="intro" class="mb-20">
            <div class="bg-white rounded-xl shadow-lg p-8 mb-12">
                <p class="text-lg text-gray-700 mb-6 drop-cap">在</p>
                <p class="text-lg text-gray-700 mb-6">高并发系统设计中，线程池大小的配置是一项关键决策，直接影响系统性能、资源利用率和稳定性。合理的配置需要平衡CPU利用率、内存消耗和响应时间等多个因素，这既是一门科学，也是一门需要经验的艺术。</p>
                <div class="grid md:grid-cols-2 gap-8 mt-8">
                    <div class="bg-indigo-50 p-6 rounded-lg">
                        <h3 class="text-xl font-semibold text-indigo-800 mb-4 flex items-center">
                            <i class="fas fa-microchip mr-3"></i>CPU密集型任务
                        </h3>
                        <p class="text-gray-700">线程数量 ≈ CPU核心数，避免过多的线程导致上下文切换开销。</p>
                    </div>
                    <div class="bg-purple-50 p-6 rounded-lg">
                        <h3 class="text-xl font-semibold text-purple-800 mb-4 flex items-center">
                            <i class="fas fa-network-wired mr-3"></i>I/O密集型任务
                        </h3>
                        <p class="text-gray-700">线程数量 ≈ CPU核心数 × (1 + 等待时间/计算时间)，充分利用I/O等待时间。</p>
                    </div>
                </div>
            </div>
        </section>

        <!-- Content Sections -->
        <section class="mb-20">
            <h2 class="text-3xl font-bold mb-8 text-center text-gray-800">
                <i class="fas fa-cogs mr-3 text-indigo-600"></i>线程池配置六大核心要素
            </h2>
            
            <!-- Task Type Section -->
            <div class="bg-white rounded-xl shadow-md overflow-hidden mb-12 card-hover">
                <div class="md:flex">
                    <div class="md:w-1/3 bg-gradient-to-b from-indigo-100 to-purple-100 p-8 flex items-center justify-center">
                        <div class="text-center">
                            <i class="fas fa-tasks text-6xl text-indigo-600 mb-4"></i>
                            <h3 class="text-2xl font-bold text-gray-800">任务类型与性质</h3>
                        </div>
                    </div>
                    <div class="md:w-2/3 p-8">
                        <div class="mb-6 highlight-box">
                            <h4 class="text-xl font-semibold text-indigo-700 mb-3">CPU密集型任务</h4>
                            <p class="text-gray-700">线程池大小通常应接近或等于CPU核心数，避免过多的上下文切换开销。</p>
                            <p class="mt-2 font-mono bg-gray-100 p-2 rounded text-indigo-700">线程池大小 ≈ CPU核心数</p>
                        </div>
                        <div class="highlight-box">
                            <h4 class="text-xl font-semibold text-purple-700 mb-3">I/O密集型任务</h4>
                            <p class="text-gray-700">线程池大小可以设置为CPU核心数的2-4倍，充分利用I/O等待时间处理其他任务。</p>
                            <p class="mt-2 font-mono bg-gray-100 p-2 rounded text-purple-700">线程池大小 ≈ CPU核心数 × 2到4</p>
                        </div>
                    </div>
                </div>
            </div>

            <!-- Task Load Section -->
            <div class="bg-white rounded-xl shadow-md overflow-hidden mb-12 card-hover">
                <div class="md:flex flex-row-reverse">
                    <div class="md:w-1/3 bg-gradient-to-b from-blue-100 to-cyan-100 p-8 flex items-center justify-center">
                        <div class="text-center">
                            <i class="fas fa-tachometer-alt text-6xl text-blue-600 mb-4"></i>
                            <h3 class="text-2xl font-bold text-gray-800">任务负载与延迟</h3>
                        </div>
                    </div>
                    <div class="md:w-2/3 p-8">
                        <div class="grid md:grid-cols-2 gap-6">
                            <div class="highlight-box">
                                <h4 class="text-xl font-semibold text-blue-700 mb-3">任务负载</h4>
                                <p class="text-gray-700">长耗时任务可增加线程数，短耗时任务可减少线程数。</p>
                                <div class="mt-3 flex items-center text-sm text-blue-600">
                                    <i class="fas fa-clock mr-2"></i>执行时间越长 → 线程数可增加
                                </div>
                            </div>
                            <div class="highlight-box">
                                <h4 class="text-xl font-semibold text-cyan-700 mb-3">任务延迟</h4>
                                <p class="text-gray-700">响应敏感任务需足够线程数减少排队时间。</p>
                                <div class="mt-3 flex items-center text-sm text-cyan-600">
                                    <i class="fas fa-stopwatch mr-2"></i>响应要求高 → 线程数需增加
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <!-- Resource Section -->
            <div class="bg-white rounded-xl shadow-md overflow-hidden mb-12 card-hover">
                <div class="md:flex">
                    <div class="md:w-1/3 bg-gradient-to-b from-amber-100 to-orange-100 p-8 flex items-center justify-center">
                        <div class="text-center">
                            <i class="fas fa-server text-6xl text-amber-600 mb-4"></i>
                            <h3 class="text-2xl font-bold text-gray-800">系统资源限制</h3>
                        </div>
                    </div>
                    <div class="md:w-2/3 p-8">
                        <div class="mb-6 highlight-box">
                            <h4 class="text-xl font-semibold text-amber-700 mb-3">硬件资源</h4>
                            <p class="text-gray-700">考虑系统的CPU和内存资源，避免线程过多导致资源耗尽。</p>
                            <div class="mt-3 flex flex-wrap gap-2">
                                <span class="px-3 py-1 bg-amber-100 text-amber-800 rounded-full text-sm flex items-center">
                                    <i class="fas fa-memory mr-1"></i> 内存限制
                                </span>
                                <span class="px-3 py-1 bg-amber-100 text-amber-800 rounded-full text-sm flex items-center">
                                    <i class="fas fa-microchip mr-1"></i> CPU核心数
                                </span>
                                <span class="px-3 py-1 bg-amber-100 text-amber-800 rounded-full text-sm flex items-center">
                                    <i class="fas fa-ethernet mr-1"></i> I/O带宽
                                </span>
                            </div>
                        </div>
                        <div class="highlight-box">
                            <h4 class="text-xl font-semibold text-orange-700 mb-3">应用特性</h4>
                            <p class="text-gray-700">Web服务器等需要根据并发请求量调整线程池大小。</p>
                            <div class="mt-2 text-sm text-orange-600 flex items-center">
                                <i class="fas fa-globe mr-2"></i>高并发应用 → 需更大线程池
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <!-- Monitoring Section -->
            <div class="bg-white rounded-xl shadow-md overflow-hidden mb-12 card-hover">
                <div class="md:flex flex-row-reverse">
                    <div class="md:w-1/3 bg-gradient-to-b from-emerald-100 to-teal-100 p-8 flex items-center justify-center">
                        <div class="text-center">
                            <i class="fas fa-chart-bar text-6xl text-emerald-600 mb-4"></i>
                            <h3 class="text-2xl font-bold text-gray-800">测试与监控</h3>
                        </div>
                    </div>
                    <div class="md:w-2/3 p-8">
                        <div class="grid md:grid-cols-2 gap-6">
                            <div class="highlight-box">
                                <h4 class="text-xl font-semibold text-emerald-700 mb-3">性能测试</h4>
                                <p class="text-gray-700">模拟生产负载测试线程池表现，找到最佳配置。</p>
                                <ul class="mt-2 text-sm text-emerald-600 space-y-1">
                                    <li class="flex items-center"><i class="fas fa-check-circle mr-2"></i>压力测试</li>
                                    <li class="flex items-center"><i class="fas fa-check-circle mr-2"></i>基准测试</li>
                                    <li class="flex items-center"><i class="fas fa-check-circle mr-2"></i>负载测试</li>
                                </ul>
                            </div>
                            <div class="highlight-box">
                                <h4 class="text-xl font-semibold text-teal-700 mb-3">动态调整</h4>
                                <p class="text-gray-700">监控线程池状态，根据负载动态调整参数。</p>
                                <ul class="mt-2 text-sm text-teal-600 space-y-1">
                                    <li class="flex items-center"><i class="fas fa-chart-pie mr-2"></i>活跃线程数</li>
                                    <li class="flex items-center"><i class="fas fa-list-ol mr-2"></i>队列长度</li>
                                    <li class="flex items-center"><i class="fas fa-stopwatch mr-2"></i>响应时间</li>
                                </ul>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <!-- Pool Config Section -->
            <div class="bg-white rounded-xl shadow-md overflow-hidden mb-12 card-hover">
                <div class="md:flex">
                    <div class="md:w-1/3 bg-gradient-to-b from-pink-100 to-rose-100 p-8 flex items-center justify-center">
                        <div class="text-center">
                            <i class="fas fa-sliders-h text-6xl text-pink-600 mb-4"></i>
                            <h3 class="text-2xl font-bold text-gray-800">线程池参数配置</h3>
                        </div>
                    </div>
                    <div class="md:w-2/3 p-8">
                        <div class="grid md:grid-cols-3 gap-4">
                            <div class="bg-pink-50 p-4 rounded-lg">
                                <h4 class="font-semibold text-pink-700 mb-2">核心线程数</h4>
                                <p class="text-sm text-gray-700">空闲时保留的线程数</p>
                            </div>
                            <div class="bg-rose-50 p-4 rounded-lg">
                                <h4 class="font-semibold text-rose-700 mb-2">最大线程数</h4>
                                <p class="text-sm text-gray-700">允许创建的最大线程数</p>
                            </div>
                            <div class="bg-pink-50 p-4 rounded-lg">
                                <h4 class="font-semibold text-pink-700 mb-2">队列容量</h4>
                                <p class="text-sm text-gray-700">任务队列的最大长度</p>
                            </div>
                            <div class="bg-rose-50 p-4 rounded-lg md:col-span-2">
                                <h4 class="font-semibold text-rose-700 mb-2">拒绝策略</h4>
                                <p class="text-sm text-gray-700">队列满时的处理策略：Abort、Discard、CallerRuns等</p>
                            </div>
                            <div class="bg-pink-50 p-4 rounded-lg">
                                <h4 class="font-semibold text-pink-700 mb-2">线程工厂</h4>
                                <p class="text-sm text-gray-700">自定义线程创建方式</p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <!-- Pool Types Section -->
            <div class="bg-white rounded-xl shadow-md overflow-hidden mb-12 card-hover">
                <div class="md:flex flex-row-reverse">
                    <div class="md:w-1/3 bg-gradient-to-b from-violet-100 to-fuchsia-100 p-8 flex items-center justify-center">
                        <div class="text-center">
                            <i class="fas fa-layer-group text-6xl text-violet-600 mb-4"></i>
                            <h3 class="text-2xl font-bold text-gray-800">线程池类型</h3>
                        </div>
                    </div>
                    <div class="md:w-2/3 p-8">
                        <div class="grid md:grid-cols-2 gap-6">
                            <div class="highlight-box">
                                <h4 class="text-xl font-semibold text-violet-700 mb-3 flex items-center">
                                    <i class="fas fa-lock mr-2"></i>FixedThreadPool
                                </h4>
                                <p class="text-gray-700">固定大小线程池，适用于任务量固定且对执行时间有要求的场景。</p>
                            </div>
                            <div class="highlight-box">
                                <h4 class="text-xl font-semibold text-fuchsia-700 mb-3 flex items-center">
                                    <i class="fas fa-sync-alt mr-2"></i>CachedThreadPool
                                </h4>
                                <p class="text-gray-700">可缓存线程池，适用于任务量变化大的场景，自动回收空闲线程。</p>
                            </div>
                            <div class="highlight-box">
                                <h4 class="text-xl font-semibold text-violet-700 mb-3 flex items-center">
                                    <i class="fas fa-clock mr-2"></i>ScheduledThreadPool
                                </h4>
                                <p class="text-gray-700">定时任务线程池，适用于定时或周期性任务。</p>
                            </div>
                            <div class="highlight-box">
                                <h4 class="text-xl font-semibold text-fuchsia-700 mb-3 flex items-center">
                                    <i class="fas fa-stream mr-2"></i>SingleThreadExecutor
                                </h4>
                                <p class="text-gray-700">单线程线程池，保证任务按顺序执行。</p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Visualization Section -->
        <section id="visualization" class="mb-20">
            <h2 class="text-3xl font-bold mb-8 text-center text-gray-800">
                <i class="fas fa-project-diagram mr-3 text-indigo-600"></i>线程池配置决策树
            </h2>
            <div class="bg-white rounded-xl shadow-lg p-8">
                <div class="mermaid">
                    graph TD
                    A[开始配置线程池] --> B{任务类型?}
                    B -->|CPU密集型| C["线程数 ≈ CPU核心数"]
                    B -->|I/O密集型| D["线程数 ≈ CPU核心数 × (1 + 等待时间/计算时间)"]
                    C --> E{系统资源充足?}
                    D --> E
                    E -->|是| F[设置核心线程数]
                    E -->|否| G[减少线程数以适应资源限制]
                    F --> H{需要快速响应?}
                    G --> H
                    H -->|是| I[适当增加最大线程数]
                    H -->|否| J[保持适中线程数]
                    I --> K[选择合适的队列容量]
                    J --> K
                    K --> L[确定拒绝策略]
                    L --> M[完成配置]
                </div>
                <div class="mt-8 bg-indigo-50 p-6 rounded-lg">
                    <h3 class="text-xl font-semibold text-indigo-800 mb-4 flex items-center">
                        <i class="fas fa-lightbulb mr-3"></i>配置示例
                    </h3>
                    <p class="text-gray-700 mb-4">假设一个处理网络请求的Web应用(8核CPU，I/O密集型):</p>
                    <ul class="space-y-2 text-gray-700">
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-indigo-500 mt-1 mr-2"></i>
                            <span>核心线程数: 8 (等于CPU核心数)</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-indigo-500 mt-1 mr-2"></i>
                            <span>最大线程数: 32 (CPU核心数 × 4)</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-indigo-500 mt-1 mr-2"></i>
                            <span>队列容量: 100 (根据预期峰值负载设置)</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-indigo-500 mt-1 mr-2"></i>
                            <span>拒绝策略: CallerRunsPolicy (由调用线程执行任务)</span>
                        </li>
                    </ul>
                </div>
            </div>
        </section>

        <!-- Summary Section -->
        <section class="bg-gradient-to-r from-indigo-500 to-purple-600 text-white rounded-xl shadow-xl p-8 mb-12">
            <h2 class="text-2xl md:text-3xl font-bold mb-6 flex items-center">
                <i class="fas fa-star mr-4"></i>线程池配置黄金法则
            </h2>
            <div class="grid md:grid-cols-3 gap-6">
                <div class="bg-white bg-opacity-10 p-4 rounded-lg backdrop-blur-sm">
                    <h3 class="text-xl font-semibold mb-3 flex items-center">
                        <i class="fas fa-balance-scale mr-2"></i>平衡之道
                    </h3>
                    <p>在CPU利用率、内存消耗和响应时间之间找到最佳平衡点。</p>
                </div>
                <div class="bg-white bg-opacity-10 p-4 rounded-lg backdrop-blur-sm">
                    <h3 class="text-xl font-semibold mb-3 flex items-center">
                        <i class="fas fa-flask mr-2"></i>测试为先
                    </h3>
                    <p>任何配置都应通过实际负载测试验证，而非仅凭理论计算。</p>
                </div>
                <div class="bg-white bg-opacity-10 p-4 rounded-lg backdrop-blur-sm">
                    <h3 class="text-xl font-semibold mb-3 flex items-center">
                        <i class="fas fa-eye mr-2"></i>监控为重
                    </h3>
                    <p>建立完善的监控体系，根据运行时数据动态调整配置。</p>
                </div>
            </div>
        </section>
    </main>

    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true,
                curve: 'basis',
                nodeSpacing: 50,
                rankSpacing: 50
            },
            themeVariables: {
                primaryColor: '#e0e7ff',
                primaryBorderColor: '#6366f1',
                primaryTextColor: '#1e293b',
                lineColor: '#a5b4fc',
                fontSize: '14px'
            }
        });
        
        // 微交互效果
        document.querySelectorAll('.card-hover').forEach(card => {
            card.addEventListener('mouseenter', () => {
                card.classList.add('shadow-xl');
            });
            card.addEventListener('mouseleave', () => {
                card.classList.remove('shadow-xl');
            });
        });
    </script>
</body>
</html>
```